/*
 * test-client.c
 *
 *  Created on: 03-11-2008
 *      Author: christian
 */
#include <dbus/dbus-glib.h>

#include <iostream>


int
main (int argc, char **argv)
{
  DBusGConnection *bus;
  DBusGProxy *remote_object_introspectable;
  DBusGProxy *remote_object_xanguli;
  DBusGProxy *remote_object_controller;
  GError *error = NULL;
  char **reply_list;
  char **reply_ptr;
  GValueArray *hello_reply_struct;
  GHashTable *hello_reply_dict;
  char *introspect_data;
  char *path;
  char *introspect_data_controller;
  guint i;

  g_type_init ();

  bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);


  remote_object_introspectable = dbus_g_proxy_new_for_name (bus,
							    "org.xanguli.Service",
							    "/Xanguli",
							    "org.freedesktop.DBus.Introspectable");
  dbus_g_proxy_call (remote_object_introspectable, "Introspect", &error,
  			  G_TYPE_INVALID,
  			  G_TYPE_STRING, &introspect_data, G_TYPE_INVALID);
  std::cout << introspect_data << "\n";
  g_free (introspect_data);
  g_object_unref (G_OBJECT (remote_object_introspectable));

  remote_object_xanguli = dbus_g_proxy_new_for_name (bus,
							    "org.xanguli.Service",
							    "/Xanguli",
							    "org.xanguli.Xanguli");
  std::cout << "Calling CreateController\n";
  dbus_g_proxy_call (remote_object_xanguli, "CreateController", &error,
    			  G_TYPE_INVALID,
    			  G_TYPE_STRING, &path, G_TYPE_INVALID);
  std::cout << "Xanguli.CreateController: " << path << "\n";

  std::cout << "Etablerer proxy for Controller\n";
  remote_object_controller = dbus_g_proxy_new_for_name(
		                        bus,
		                        "org.xanguli.Service",
		                        path,
		                        "org.xanguli.Controller");
}
